import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ComplaintVO, ComplaintForm, ComplaintQuery, ComplaintFormDTO } from '@/api/fill/execute/complaint/types';

/**
 * 查询申诉列表
 * @param query
 * @returns
 */

export const listComplaint = (query?: ComplaintQuery) => {
  return request({
    url: '/execute/complaint/list',
    method: 'post',
    data: query
  });
};

/**
 * 查询申诉详细
 * @param id
 */
export const getComplaint = (id: string | number): AxiosPromise<ComplaintVO> => {
  return request({
    url: '/execute/complaint/' + id,
    method: 'get'
  });
};

/**
 * 新增申诉
 * @param data
 */
export const addComplaint = (data: ComplaintForm) => {
  return request({
    url: '/execute/complaint',
    method: 'post',
    data: data
  });
};

/**
 * 修改申诉
 * @param data
 */
export const updateComplaint = (data: ComplaintForm) => {
  return request({
    url: '/execute/complaint',
    method: 'put',
    data: data
  });
};

/**
 * 删除申诉
 * @param id
 */
export const delComplaint = (id: string | number | Array<string | number>) => {
  return request({
    url: '/execute/complaint/' + id,
    method: 'delete'
  });
};

/**
 * 提交
 * @param id
 */
export const submitComplaint = (id: string | number) => {
  return request({
    url: '/execute/complaint/submit/' + id,
    method: 'get'
  });
};

/**
 * 审批
 * @param data
 */
export const approval = (data: ComplaintFormDTO) => {
  return request({
    url: '/execute/complaint/approval',
    method: 'post',
    data: data
  });
};
